package com.jixiantubu.adapter;

import image.SmartImageView;
import java.util.List;
import com.example.jixiantubu.R;
import com.jixiantubu.bean.Travelsbean;
import com.jixiantubu.util.MyApplication;
import com.lidroid.xutils.BitmapUtils;
import com.lidroid.xutils.HttpUtils;
import android.content.Context;
import android.util.Log;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.TextView;

public class YoujishoucangAdapter extends BaseAdapter {
	Context context;
	List<Travelsbean> list;
	LayoutInflater mInflater;
	ViewHolder mhHolder;
	BitmapUtils bitmapUtils;
	MyApplication application;
	HttpUtils httpUtils = new HttpUtils();

	public YoujishoucangAdapter(Context context, List<Travelsbean> list) {
		super();
		this.context = context;
		this.list = list;
		mInflater = LayoutInflater.from(context);
		bitmapUtils = new BitmapUtils(context);
	}

	@Override
	public int getCount() {
		// TODO Auto-generated method stub
		return list.size();
	}

	@Override
	public Object getItem(int arg0) {
		// TODO Auto-generated method stub
		return list.get(arg0);
	}

	@Override
	public long getItemId(int arg0) {
		// TODO Auto-generated method stub
		return arg0;
	}

	class ViewHolder {
		SmartImageView imageView;
		TextView textView1, textView2, textView3;

	}

	@Override
	public View getView(int arg0, View arg1, ViewGroup arg2) {
		if (arg1 == null) {
			arg1 = mInflater.inflate(R.layout.youji_shoucang_item, null);
			mhHolder = new ViewHolder();
			mhHolder.imageView = (SmartImageView) arg1
					.findViewById(R.id.wo_shoucang_tupian);
			mhHolder.textView1 = (TextView) arg1
					.findViewById(R.id.youjishoucang_biaoti);
			mhHolder.textView2 = (TextView) arg1
					.findViewById(R.id.youjishoucang_shijian);
			mhHolder.textView3 = (TextView) arg1
					.findViewById(R.id.youjishoucang_quxiaoshoucang);
			arg1.setTag(mhHolder);
		} else {
			mhHolder = (ViewHolder) arg1.getTag();
		}
		mhHolder.textView1.setText(list.get(arg0).getT_tittle());
		mhHolder.textView2.setText(list.get(arg0).getT_time());
		mhHolder.textView3.setText("已收藏");
		if(list.get(arg0).getPl_path()==null||list.get(arg0).getPl_path().size()==0){
//			mhHolder.imageView.setBackgroundResource(R.drawable.wo_beijing);
		}else{
			System.out.println("list.get(arg0).getPl_path()"+list.get(arg0).getPl_path()); 
			String url = "http://" + MyApplication.getIP() + ":8080/Jinnang/img/"
					+ list.get(arg0).getPl_path().get(0).getpl_path();
			Log.e("imagepath+我的图片", url);
			mhHolder.imageView.setImageUrl(url);
		}
		
		return arg1;
	}

}
